import Opt from '@/components/dt/info/Opt.js'
import organizationOpt from '@/biz/option/organization.js'
let _this = null
class SearchOpt extends Opt {

  constructor(vm) {
    super()
    _this = vm
    this.build()
  }

  build() {
    this.createAll()
    this.opts.push(...this.all)
  }


  createAll() {
    let cityAttrSort = [];
    this.all = [
      organizationOpt.create({
        key: 'orgIds'
      }),
      // houseOpt.create({
      //   to: (info) => {
      //     return {
      //       housesId: info.housesId
      //     }
      //   }
      // }),
      {
        key: 'city',
        title: '所属城市',
        load: (o) => {
          organizationOpt.getAreacodePropertyList().then(res => {
            o.cascader.options = res
            cityAttrSort = res
          })
        },
        cascader: {
          options: cityAttrSort,

          loadData(item, callback) {
            console.log(item, 'aaaaaaaaaaa');
            item.loading = true;
            let params = {
              level: 3,
              page: "1",
              parentCode: item.value,
              rows: "100",
            };
            organizationOpt.getAreacodePropertyList2(params).then((res) => {
              res.list.map((itemL) => {
                itemL.value = itemL.cityCode;
                itemL.label = itemL.cityName;
                item.children.push(itemL);
              });

              item.loading = false;
              callback();
            });
          }
        }
      },
      {
        title: '案场名字',
        placeholder: '请输入案场名字',
        key: 'housesName',
        input: {}
      },
    ]
  }
}

export default SearchOpt